Skip to content

Fix NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS compilation error #3826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

nikitabobko
Copy link
Member

The compilation error appeared after KT-59665

The compilation error appeared after KT-59665
@nikitabobko nikitabobko added the kotlin-merge-blocker PRs labeled as merge-blockers are effectively preventing a corresponding merge into main Kotlin repo label Jul 25, 2023
@nikitabobko
Copy link
Member Author

@@ -54,6 +54,7 @@ public actual typealias TestResult = Unit
* }
* ```
*/
@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS") // Counterpart for ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please elaborate on how we should proceed further with this suppress?

If this case is no longer supported (or was unsupported but not explicitly reported), shouldn't we have any kind of migration plan?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suppress is a counterpart for @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS"). You can see that you already have a @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS") inside public actual open class TestBase.

If you didn't have @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS") then NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS wouldn't be reported

Copy link
Member Author

@nikitabobko nikitabobko Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I had to rework the way we report ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS. Before my changes, it was a separate checker. Now it's checked in the expect-actual matcher and it's considered a common expect-actual mismatch incompatibility

And such types of expect-actual mismatch incompatibilities are reported two times:

// Common
expect class Bar {
    fun foo(): Any
}

// Platform
actual class Bar { // NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS (first time)
    actual fun foo(): String { // ACTUAL_WITHOUT_EXPECT (second time)
        return ""
    }
}

That's why you need to suppress ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS two times (But they are two separate diagnostics)

Copy link
Member Author

@nikitabobko nikitabobko Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it will be more clear If I change Counterpart for ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS comment to Counterpart for @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full compilation error of NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS also makes it clear:

e: file:///home/bobko/jb/test-proj/kotlinx.coroutines/kotlinx-coroutines-core/jvm/test/TestBase.kt:57 Actual class 'TestBase' has no corresponding members for expected class members:

    public expect fun error(message: Any, cause: Throwable?): Nothing

    The following declaration is incompatible because actual function cannot have default argument values, they should be declared in the expected function:
        public actual fun error(message: Any, cause: Throwable? = null): Nothing

@qwwdfsad qwwdfsad self-requested a review July 25, 2023 16:20
@nikitabobko
Copy link
Member Author

Let's please wait for the accept in https://jetbrains.team/p/kt/reviews/11039/timeline before merging. Maybe the plan will change. I will ping you here once the status of the https://jetbrains.team/p/kt/reviews/11039/timeline changes

@nikitabobko
Copy link
Member Author

nikitabobko commented Aug 9, 2023

The review in Kotlin is done.

@qwwdfsad can you please merge it? (please note the fixup! commit. It must be squashed)

@mshishkina can you please cherry-pick it to kotlin-community/dev?

@qwwdfsad qwwdfsad merged commit db57e08 into develop Aug 9, 2023
@qwwdfsad qwwdfsad deleted the bobko/MR/default-params-actual branch August 9, 2023 13:50
nikitabobko added a commit that referenced this pull request Aug 9, 2023
@mshishkina mshishkina assigned mshishkina and woainikk and unassigned mshishkina Aug 10, 2023
PavelPunegov pushed a commit that referenced this pull request Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kotlin-merge-blocker PRs labeled as merge-blockers are effectively preventing a corresponding merge into main Kotlin repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants